package com.atguigu.gmall.item.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.SkuDetailService;
import com.atguigu.gmall.web.SkuDetailVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:ahang
 * @create:2022-10-04 18:36
 * @Description:
 */
@RestController
@RequestMapping("/api/inner/item")
@Slf4j
public class SkuDetailController {

    @Autowired
    SkuDetailService skuDetailService;

    /**
     * 显示详情页
     * @param skuId
     * @return
     */
    @GetMapping("/detail/{skuId}")
    public Result<SkuDetailVo> skuDetail(@PathVariable("skuId") Long skuId){
        SkuDetailVo skuDetailVo = skuDetailService.skuDetail(skuId);
//        log.info("正在查询{}号元素",skuId);
        //每点击依次增加商品热度
        skuDetailService.incrHotSccore(skuId);

        return Result.ok(skuDetailVo);
    }
}
